package cn.fl.project.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.upload.constant.UploadConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.api.IUploadApiService;
import cmm.comm.facade.upload.condition.SysUlDatCfgQueryCondition;
import cmm.comm.facade.upload.dto.SysUlDatCfgDTO;
import cmm.comm.facade.upload.dto.SysUlDatCfgDtlDTO;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.condition.PrjFileInfoQueryCondition;
import cn.fl.project.constant.PrjFileInfoConstant;
import cn.fl.project.service.IPrjFileInfoService;
import cn.fl.project.vo.PrjFileInfoVO;
import fl.customer.facade.customer.api.ICustomerQueryApiService;
import fl.customer.facade.customer.constant.CustomerConstant;
import fl.customer.facade.customer.dto.CstBscInfoDTO;


@Service
public class PrjFileInfoServiceImpl implements IPrjFileInfoService {

    @SuppressWarnings("unused")
    private static final Logger logger = LoggerFactory.getLogger(PrjFileInfoServiceImpl.class);

    @Autowired
    private IUploadApiService uploadApiService;

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    @Autowired
    private ICustomerQueryApiService customerQueryApiService;
    @Autowired
    private IPrjBscInfoService prjBscInfoService;

    @Override
    public List<PrjFileInfoVO> searchCstFileInfoCfgList(PrjFileInfoQueryCondition condition) throws BaseException {
        //查询客户信息 -> 获取客户类型
        String cfgCd = "";//客户上传资料 配置编号
        CstBscInfoDTO cstBscInfoDTO = this.customerQueryApiService.getCstBscInfoById(condition.getCstId());
        String cstTypCd = cstBscInfoDTO.getCstTypCd();
        if (CustomerConstant.CST_TYP_CD_NP.equals(cstTypCd)) {//自然人
            cfgCd = PrjFileInfoConstant.CODE_UL_CST_NP_FILE_CFG_CD;
        } else {
            cfgCd = PrjFileInfoConstant.CODE_UL_CST_CORP_FILE_CFG_CD;//法人
        }

        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());//组织架构代码
        //ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getCstId()));//客户ID
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(cfgCd);
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号
        //查询上传资料配置明细
        List<SysUlDatCfgDTO> sysUlDatCfgDTOList = this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(sysUlDatCfgDTOList)) {
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            for (SysUlDatCfgDTO cfgDTO : sysUlDatCfgDTOList) {
                for (SysUlDatCfgDtlDTO cfgDtlDTO : cfgDTO.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    //vo.setId(condition.getCstId());
                    vo.setCfgCd(cfgDTO.getCfgCd());//配置编号
                    vo.setCfgNm(cfgDTO.getCfgNm());//配置名称
                    vo.setCfgDtlCd(cfgDtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(cfgDtlDTO.getDatNm());//资料名称

                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    @Override
    public List<PrjFileInfoVO> searchCstFileInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
        //查询客户信息 -> 获取客户类型
        String cfgCd = "";//客户上传资料 配置编号
        CstBscInfoDTO cstBscInfoDTO = this.customerQueryApiService.getCstBscInfoById(condition.getCstId());
        String cstTypCd = cstBscInfoDTO.getCstTypCd();
        if (CustomerConstant.CST_TYP_CD_NP.equals(cstTypCd)) {//自然人
            cfgCd = PrjFileInfoConstant.CODE_UL_CST_NP_FILE_CFG_CD;
        } else {
            cfgCd = PrjFileInfoConstant.CODE_UL_CST_CORP_FILE_CFG_CD;//法人
        }

        condition.setCfgCd(cfgCd);//配置编号
        condition.setDataId(condition.getCstId());//数据主键-客户ID
        return this.getUploadFileList(condition);

		/*SysUlFilesRecQueryCondition sysUlFilesRecQueryCondition = new SysUlFilesRecQueryCondition();
		sysUlFilesRecQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
		sysUlFilesRecQueryCondition.setOrgCd(CapitalConstant.SYSORG);//组织架构代码
		sysUlFilesRecQueryCondition.setCfgCd(cfgCd);//配置编号
		//sysUlFilesRecQueryCondition.setCfgDtlCd(condition.getCfgDtlCd());//配置子编号
		sysUlFilesRecQueryCondition.setPkId(String.valueOf(condition.getCstId()));//数据主键-客户ID

		//查询子配置下文件上传记录
		List<SysUlFilesRecDTO> sysUlFilesRecDTOList = this.uploadApiService.searchSysUlFilesRecList(sysUlFilesRecQueryCondition);
		List<PrjFileInfoVO> voList = null;
		if(CollectionUtils.isNotEmpty(sysUlFilesRecDTOList)){
			Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
			voList = new ArrayList<>();
			PrjFileInfoVO vo;
			for (SysUlFilesRecDTO sysUlFilesRecDTO : sysUlFilesRecDTOList) {
				vo = new PrjFileInfoVO();
				vo.setId(condition.getCstId());
				vo.setCfgDtlCd(sysUlFilesRecDTO.getCfgDtlCd());//配置子编号
				vo.setDatNm(sysUlFilesRecDTO.getDatNm());//配置名称
				vo.setCfgCd(sysUlFilesRecDTO.getCfgCd());//配置编号
				vo.setFileId(sysUlFilesRecDTO.getId());//附件ID
				vo.setFilePath(sysUlFilesRecDTO.getFilePath());//附件路径
				vo.setFileNm(sysUlFilesRecDTO.getFileNm());//上传名称
				vo.setCrtTm(sysUlFilesRecDTO.getCrtTm());//上传时间
				if (StringUtils.isNotBlank(sysUlFilesRecDTO.getAudStsCd())) {
					vo.setAudStsCd(sysUlFilesRecDTO.getAudStsCd());//验证状态
				} else {
					vo.setAudStsCd("0");//验证状态
				}

				if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
					vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
				}
				voList.add(vo);
			}

		}

		return voList;*/
    }

    @Override
    public List<PrjFileInfoVO> searchPrjFileInfoCfgList(PrjFileInfoQueryCondition condition) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());//组织架构代码
        List<String> cfgCdList = new ArrayList<>();
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号
        cfgCdList.add(PrjFileInfoConstant.CODE_UL_PRJ_FILE_CFG_CD);//项目上传资料 配置编号
        List<SysUlDatCfgDTO> sysUlDatCfgDTOList = this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(sysUlDatCfgDTOList)) {
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            for (SysUlDatCfgDTO cfgDTO : sysUlDatCfgDTOList) {
                for (SysUlDatCfgDtlDTO cfgDtlDTO : cfgDTO.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    vo.setCfgCd(cfgDTO.getCfgCd());//配置编号
                    vo.setCfgNm(cfgDTO.getCfgNm());//配置名称
                    vo.setCfgDtlCd(cfgDtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(cfgDtlDTO.getDatNm());//资料名称

                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    @Override
    public List<PrjFileInfoVO> searchPrjSupplementInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
//        //查询所有项目资料
//        List<PrjFileInfoVO> prjFileInfoVOS = this.searchPrjFileInfoList(condition);
//        //查询贷后补充资料配置
//        SysUlDatCfgQueryCondition sysUlDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
//        sysUlDatCfgQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());
//        if(StringUtils.isNotEmpty(condition.getCstMgrOrgCd())){
//            sysUlDatCfgQueryCondition.setOrgCd(condition.getCstMgrOrgCd());//客户经理组织架构代码
//        }else{
//            sysUlDatCfgQueryCondition.setOrgCd(CapitalConstant.SYSORG);
//        }
//        List<String> cfgCdList = new ArrayList<>();
//        cfgCdList.add(PrjFileInfoConstant.CODE_UL_PRJ_SUPP_FILE_CFG_CD);//配置编号
//        sysUlDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
//        List<SysUlDatCfgDTO> sysUlDatCfgDTOS = uploadApiService.searchSysUlDatCfgList(sysUlDatCfgQueryCondition);
//        //筛选贷后补充资料
//        List<PrjFileInfoVO> uploadFileList = new ArrayList<PrjFileInfoVO>();
//        for(PrjFileInfoVO prjFileInfoVO:prjFileInfoVOS){
//            List<SysUlDatCfgDtlDTO> sysUlDatCfgDtlDTOList = sysUlDatCfgDTOS.get(0).getSysUlDatCfgDtlDTOList();
//            for(SysUlDatCfgDtlDTO sysUlDatCfgDtlDTO:sysUlDatCfgDtlDTOList){
//                if(sysUlDatCfgDtlDTO.getCfgDtlCd().equals(prjFileInfoVO.getCfgDtlCd())){
//                    uploadFileList.add(prjFileInfoVO);
//                }
//            }
//        }
        condition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_SUPP_FILE_CFG_CD);//配置编号
        condition.setDataId(condition.getPrjId());//数据主键-ID
        List<PrjFileInfoVO> uploadFileList = this.getUploadFileList(condition);
        return uploadFileList;
    }
    @Override
    public List<PrjFileInfoVO> searchPrjFileInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
        condition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_FILE_CFG_CD);//配置编号
        condition.setDataId(condition.getPrjId());//数据主键-项目ID
        if(StringUtils.isNotBlank(condition.getPrjTypCd())){
            if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYW.equals(condition.getPrjTypCd())){
                condition.setCfgCd(PrjFileInfoConstant.CDDYW_PRJ_FILE_CFG_CD);//配置编号
            }
        }else{
            if(StringUtils.isNotEmpty(condition.getPrjId())){
                PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(condition.getPrjId());
                //项目资料配置代码   车抵贷业务：PRJ022  其他：PRJ016
                if(null!=prjBscInfoVO && StringUtils.isNotBlank(prjBscInfoVO.getPrjTypCd()) && PrjBscInfoConstant.PRJ_TYP_CD_CDDYW.equals(prjBscInfoVO.getPrjTypCd())){
                    condition.setCfgCd(PrjFileInfoConstant.CDDYW_PRJ_FILE_CFG_CD);//配置编号
                }
            }
        }
        return this.getUploadFileList(condition);

		/*SysUlFilesRecQueryCondition sysUlFilesRecQueryCondition = new SysUlFilesRecQueryCondition();
		sysUlFilesRecQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
		sysUlFilesRecQueryCondition.setOrgCd(CapitalConstant.SYSORG);//组织架构代码
		sysUlFilesRecQueryCondition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_FILE_CFG_CD);//配置编号
		//sysUlFilesRecQueryCondition.setCfgDtlCd(condition.getCfgDtlCd());//配置子编号
		sysUlFilesRecQueryCondition.setPkId(String.valueOf(condition.getPrjId()));//数据主键-项目ID

		//查询子配置下文件上传记录
		List<SysUlFilesRecDTO> sysUlFilesRecDTOList = this.uploadApiService.searchSysUlFilesRecList(sysUlFilesRecQueryCondition);
		List<PrjFileInfoVO> voList = null;
		if(CollectionUtils.isNotEmpty(sysUlFilesRecDTOList)){
			Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
			voList = new ArrayList<>();
			PrjFileInfoVO vo;
			for (SysUlFilesRecDTO sysUlFilesRecDTO : sysUlFilesRecDTOList) {
				vo = new PrjFileInfoVO();
				vo.setId(condition.getPrjId());
				vo.setCfgDtlCd(sysUlFilesRecDTO.getCfgDtlCd());//配置子编号
				vo.setDatNm(sysUlFilesRecDTO.getDatNm());//配置名称
				vo.setCfgCd(sysUlFilesRecDTO.getCfgCd());//配置编号
				vo.setFileId(sysUlFilesRecDTO.getId());//附件ID
				vo.setFilePath(sysUlFilesRecDTO.getFilePath());//附件路径
				vo.setFileNm(sysUlFilesRecDTO.getFileNm());//上传名称
				vo.setCrtTm(sysUlFilesRecDTO.getCrtTm());//上传时间
				if (StringUtils.isNotBlank(sysUlFilesRecDTO.getAudStsCd())) {
					vo.setAudStsCd(sysUlFilesRecDTO.getAudStsCd());//验证状态
				} else {
					vo.setAudStsCd("0");//验证状态
				}

				if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
					vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
				}
				voList.add(vo);
			}

		}
		return voList;*/
    }
    @Override
    public List<PrjFileInfoVO> searchPrjLionCstFileInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
        condition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_LION_CST_FILE_CFG_CD);//配置编号
        condition.setDataId(condition.getPrjId());//数据主键-项目ID
        return this.getUploadFileList(condition);

    }
    @Override
    public List<PrjFileInfoVO> searchPrjTrigonalCstFileInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
        condition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_TRIGONAL_CST_FILE_CFG_CD);//配置编号
        condition.setDataId(condition.getPrjId());//数据主键-项目ID
        return this.getUploadFileList(condition);

    }

    @Override
    public List<PrjFileInfoVO> searchFileInfoListByCfgCd(PrjFileInfoQueryCondition condition) throws BaseException {
        return this.getUploadFileList(condition);
    }

    @Override
    public List<PrjFileInfoVO> searchPrjPrdDtlFileInfoCfgList(PrjFileInfoQueryCondition condition) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
        ulDatCfgQueryCondition.setOrgCd(CurrentThreadContext.getCurrentOrgCd());//组织架构代码
        List<String> cfgCdList = new ArrayList<>();
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号
        cfgCdList.add(PrjFileInfoConstant.CODE_UL_PRJ_PRD_DTL_FILE_CFG_CD);//租赁物上传资料 配置编号
        List<SysUlDatCfgDTO> sysUlDatCfgDTOList = this.uploadApiService.searchSysUlDatCfgList(ulDatCfgQueryCondition);
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(sysUlDatCfgDTOList)) {
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            for (SysUlDatCfgDTO cfgDTO : sysUlDatCfgDTOList) {
                for (SysUlDatCfgDtlDTO cfgDtlDTO : cfgDTO.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    vo.setCfgCd(cfgDTO.getCfgCd());//配置编号
                    vo.setCfgNm(cfgDTO.getCfgNm());//配置名称
                    vo.setCfgDtlCd(cfgDtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(cfgDtlDTO.getDatNm());//资料名称

                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    @Override
    public List<PrjFileInfoVO> searchPrjPrdDtlFileInfoList(PrjFileInfoQueryCondition condition) throws BaseException {
        condition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_PRD_DTL_FILE_CFG_CD);//配置编号
        condition.setDataId(condition.getPrjPrdDtlId());//数据主键-项目产品明细ID
        if(StringUtils.isNotBlank(condition.getPrjTypCd())){
            if(PrjBscInfoConstant.PRJ_TYP_CD_CDDYW.equals(condition.getPrjTypCd())){
                condition.setCfgCd(PrjFileInfoConstant.CDDYW_PRD_FILE_CFG_CD);//配置编号
            }
        }else{
            if(StringUtils.isNotEmpty(condition.getPrjId())){
                PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(condition.getPrjId());
                //租赁物资料配置代码   车抵贷业务：PRJ023  其他：PRJ015
                if(null!=prjBscInfoVO && StringUtils.isNotBlank(prjBscInfoVO.getPrjTypCd()) && PrjBscInfoConstant.PRJ_TYP_CD_CDDYW.equals(prjBscInfoVO.getPrjTypCd())){
                    condition.setCfgCd(PrjFileInfoConstant.CDDYW_PRD_FILE_CFG_CD);//配置编号
                }
            }
        }
        return this.getUploadFileList(condition);
		/*SysUlFilesRecQueryCondition sysUlFilesRecQueryCondition = new SysUlFilesRecQueryCondition();
		sysUlFilesRecQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
		sysUlFilesRecQueryCondition.setOrgCd(CapitalConstant.SYSORG);//组织架构代码
		sysUlFilesRecQueryCondition.setCfgCd(PrjFileInfoConstant.CODE_UL_PRJ_PRD_DTL_FILE_CFG_CD);//配置编号
		//sysUlFilesRecQueryCondition.setCfgDtlCd(condition.getCfgDtlCd());//配置子编号
		sysUlFilesRecQueryCondition.setPkId(String.valueOf(condition.getPrjPrdDtlId()));//数据主键-项目产品明细ID

		//查询子配置下文件上传记录
		List<SysUlFilesRecDTO> sysUlFilesRecDTOList = this.uploadApiService.searchSysUlFilesRecList(sysUlFilesRecQueryCondition);
		List<PrjFileInfoVO> voList = null;
		if(CollectionUtils.isNotEmpty(sysUlFilesRecDTOList)){
			Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
			voList = new ArrayList<>();
			PrjFileInfoVO vo;
			for (SysUlFilesRecDTO sysUlFilesRecDTO : sysUlFilesRecDTOList) {
				vo = new PrjFileInfoVO();
				vo.setId(condition.getPrjPrdDtlId());
				vo.setCfgDtlCd(sysUlFilesRecDTO.getCfgDtlCd());//配置子编号
				vo.setDatNm(sysUlFilesRecDTO.getDatNm());//配置名称
				vo.setCfgCd(sysUlFilesRecDTO.getCfgCd());//配置编号
				vo.setFileId(sysUlFilesRecDTO.getId());//附件ID
				vo.setFilePath(sysUlFilesRecDTO.getFilePath());//附件路径
				vo.setFileNm(sysUlFilesRecDTO.getFileNm());//上传名称
				vo.setCrtTm(sysUlFilesRecDTO.getCrtTm());//上传时间
				if (StringUtils.isNotBlank(sysUlFilesRecDTO.getAudStsCd())) {
					vo.setAudStsCd(sysUlFilesRecDTO.getAudStsCd());//验证状态
				} else {
					vo.setAudStsCd("0");//验证状态
				}

				if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
					vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
				}
				voList.add(vo);
			}

		}
		return voList;*/
    }

    @Override
    public boolean modifyFileAudStsCd(Long fileId, String audStsCd) throws BaseException {
        return this.uploadApiService.modifySysUlFilesRecAudStsCdById(fileId, audStsCd);
    }

    @Override
    public boolean removeFile(Long fileId) throws BaseException {
        List<Long> idList = new ArrayList<>(1);
        idList.add(fileId);
        return this.uploadApiService.removeSysUlFilesRecByIds(idList);
    }

    @Override
    public boolean modifyFileAudStsCdList(List<Long> fileIdList, String audStsCd) throws BaseException {
        return this.uploadApiService.modifySysUlFilesRecAudStsCdByIdList(fileIdList, audStsCd);
    }

    private List<PrjFileInfoVO> getUploadFileList(PrjFileInfoQueryCondition condition) throws BaseException {
        //查询资料配置，系统代码,组织架构代码,配置编号 ,业务主键
        SysUlDatCfgQueryCondition ulDatCfgQueryCondition = new SysUlDatCfgQueryCondition();
        ulDatCfgQueryCondition.setSysCd(CurrentThreadContext.getCurrentSysCd());//系统代码
        if(StringUtils.isNotEmpty(condition.getCstMgrOrgCd())){
            ulDatCfgQueryCondition.setOrgCd(condition.getCstMgrOrgCd());//客户经理组织架构代码
        }else{
            ulDatCfgQueryCondition.setOrgCd(CapitalConstant.SYSORG);
        }

        ulDatCfgQueryCondition.setDataId(String.valueOf(condition.getDataId()));//业务主键
        List<String> cfgCdList = new ArrayList<>();
        cfgCdList.add(condition.getCfgCd());//配置编号
        ulDatCfgQueryCondition.setCfgCdList(cfgCdList);//配置编号集合
        List<SysUlDatCfgDTO> list = uploadApiService.searchSysUlDatCfgListByDataId(ulDatCfgQueryCondition);
        List<PrjFileInfoVO> voList = null;
        if (CollectionUtils.isNotEmpty(list)) {
            Map<String, String> audStsCdMap = this.sysDictionaryApiService.searchGroupToMap(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), CapitalConstant.CODE_MATE_AUD_STS_CD);
            voList = new ArrayList<>();
            PrjFileInfoVO vo;
            //设置路径
            String picServicePath = PropertiesCacheUtils.getProperty(UploadConstant.UPLOAD_SERVER_PATH);
            for (SysUlDatCfgDTO dto : list) {
                for (SysUlDatCfgDtlDTO dtlDTO : dto.getSysUlDatCfgDtlDTOList()) {
                    vo = new PrjFileInfoVO();
                    vo.setId(condition.getDataId());//业务主键
                    vo.setCfgDtlCd(dtlDTO.getCfgDtlCd());//配置子编号
                    vo.setDatNm(dtlDTO.getDatNm());//配置名称
                    vo.setCfgCd(dtlDTO.getCfgCd());//配置编号
                    vo.setOrgCd(dtlDTO.getOrgCd());//配置组织架构代码
                    vo.setCfgNm(dto.getCfgNm());//配置子名称
                    vo.setFileId(dtlDTO.getRecId());//附件ID
                    //如果有HTTP开头说明是可以访问路径,无需干涉
                    if(StringUtils.isNotBlank(dtlDTO.getFilePath()) && !dtlDTO.getFilePath().startsWith("http") && StringUtils.isNotBlank(picServicePath)){
                        vo.setFilePath(picServicePath+dtlDTO.getFilePath());
                    }else{
                        vo.setFilePath(dtlDTO.getFilePath());
                    }
                    vo.setFileNm(dtlDTO.getRecFileNm());//上传名称
                    vo.setCrtTm(dtlDTO.getRecCrtTm());//上传时间
                    vo.setIsMust(dtlDTO.getIsMust());//是否必传
                    if (StringUtils.isNotBlank(dtlDTO.getRecAudStsCd())) {
                        vo.setAudStsCd(dtlDTO.getRecAudStsCd());//验证状态
                    } else {
                        vo.setAudStsCd("0");//验证状态
                    }

                    if (audStsCdMap != null && audStsCdMap.containsKey(vo.getAudStsCd())) {
                        vo.setAudStsCdNm(audStsCdMap.get(vo.getAudStsCd()));
                    }
                    voList.add(vo);
                }
            }
        }
        return voList;
    }

    @Override
    public List<PrjFileInfoVO> searchPrdDtlBackOffFileList(PrjFileInfoQueryCondition condition) throws BaseException {
        condition.setCfgCd(condition.getCfgCd());//配置编号
        condition.setDataId(condition.getPrjPrdDtlId());//数据主键-项目产品明细ID
        return this.getUploadFileList(condition);
    }
}
